<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        window.addEventListener('load', function () {
            if (navigator.geolocation) {
                navigator.geolocation.watchPosition(update)
            }
        }, false)

        function update(position) {
            var lat = position.coords.latitude;
            var lng = position.coords.longitude;
            console.log('维度：' + lat + ', 经度：' + lng);
            document.write('维度：' + lat + ', 经度：' + lng);
        }
    </script>
</body>

</html>